﻿// See https://aka.ms/new-console-template for more information
using EasyNetQ;
using RabbitMessage;

Console.WriteLine("Hello, World!");
// 
using (var bus = RabbitHutch.CreateBus("host=192.168.95.11;port=5672;virtualHost=cap-vhost;username=cap;password=cap123456;requestedHeartbeat=10", s => s.EnableSystemTextJson()))
{
    bus.PubSub.Subscribe<TextMessage>("test", HandleTextMessage, configure => configure.WithTopic("OrderMessage"));
    Console.WriteLine("Listening for messages. Hit <return> to quit.");
    Console.ReadLine();
}

static void HandleTextMessage(TextMessage textMessage)
{
    Console.ForegroundColor = ConsoleColor.Red;
    Console.WriteLine("我报错了怎么办？:{0}", textMessage.Text);
    Console.ResetColor();
    throw new ArgumentOutOfRangeException();
}